int copy_file(char* src, char* dest)
{
	int destFD, srcFD, bytesRead;
	char buf[MAX_BLOCK_SIZE];
	
	srcFD = open_file(src, FILE_READ);
	if (srcFD < 0)
		return -1;
	
	/* Check if dest needs to be created */
	if (get_inode_number(dest).inodeNum == 0)
	{
		if (do_create(dest) == -1)
		{
			close_file(srcFD);
			return -1;
		}
	}

	/* Open dest */		
	destFD = open_file(dest, FILE_WRITE);
	if (destFD < 0)
	{
		close_file(srcFD);
		return -1;
	}
	
	/* Make sure not trying to copy to myself */
	if (destFD == srcFD)
	{
		printf("Cannot copy file to itself!\n\n");
		close_file(srcFD);
		close_file(destFD);
		return -1;
	}
	
	do
	{
		bytesRead = read_file(srcFD, buf, MAX_BLOCK_SIZE);
		write_file(destFD, buf, bytesRead);
	} while (bytesRead);
	
	close_file(srcFD);
	close_file(destFD);
	putchar('\n');
}

int do_cp(char* args)
{
	char* dest, *src;
	char fullDestPath[MAX_PATH_LENGTH];
	char fullSrcPath[MAX_PATH_LENGTH];
	
	if (strchr(args, ' ') == 0)
	{
		printf("Not enough args\n");
		return -1;
	}
	
	src = strtok(args, " ");
	dest  = strtok(0, " \n");
	
	if (src[0] != '/')
	{
		char tmp[MAX_PATH_LENGTH];
		get_pwd_name(runningProc->cwd, tmp);
		strcat(tmp, src);
		strcpy(fullSrcPath, tmp);
	}
	else
		strcpy(fullSrcPath, src);
		
	if (dest[0] != '/')
	{
		char tmp[MAX_PATH_LENGTH];
		get_pwd_name(runningProc->cwd, tmp);
		strcat(tmp, dest);
		strcpy(fullDestPath, tmp);
	}
	else
		strcpy(fullDestPath, dest);
	
	return copy_file(fullSrcPath, fullDestPath);
}
